package common;

import util.remote.RemoteConf;

import java.util.Calendar;

/**
 * 常量
 * <p>
 * Created by J.Chen on 2017/5/22.
 */
public class Constants {

    /**
     * 公钥路径
     */
    public static final String jykgAuthor = "D:\\工作\\常用配置\\ssh_host_rsa_key.jykg";
    /**
     * 公钥路径
     */
    public static final String qcloudAuthor = "D:\\工作\\常用配置\\ssh_host_rsa_key.qcloud";
    /**
     * 远程服务器配置路径
     */
    public static final String remoteConfDir = "D:\\工作\\常用配置\\remoteConf\\";

    /**
     * 文件输出路径
     */
    public static final String outputDir = "D:\\act_data\\";



    /**
     * 自动拼接输出文件路径
     *
     * @param conf
     * @param values
     * @return
     */
    @Deprecated
    public static String getActOutputDir(RemoteConf conf, String... values) {
        return String.format(outputDir + String.join(".", values) + "." + conf.getRemoteType() + ".txt");
    }


    /**
     * 获取周一的日期 格式 20170102 用于作为以星期为单位的标记
     *
     * @return
     */
    public static int getMonday() {
        Calendar cal = Calendar.getInstance();
        cal.setFirstDayOfWeek(Calendar.MONDAY);
        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        return getDaysOfToday(cal);
    }

    /**
     * 获取上周一的日期 格式 20170102
     *
     * @return
     */
    public static int getLastMonday() {
        Calendar cal = Calendar.getInstance();
        cal.setFirstDayOfWeek(Calendar.MONDAY);
        cal.add(Calendar.DATE, -7);
        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        return getDaysOfToday(cal);
    }


    /**
     * 获取日期：20160815
     */
    public static int getDaysOfToday(Calendar calendar) {
        return calendar.get(Calendar.YEAR) * 10000 + (calendar.get(Calendar.MONTH) + 1) * 100
                + calendar.get(Calendar.DAY_OF_MONTH);
    }

}
